﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/BodyMasterPage.Master"
    CodeBehind="wfGestionDescMnt.aspx.cs" Inherits="RH.wfGestionDescMnt" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%@ Import Namespace="Texfina.Common.Mg" %>
<%@ Import Namespace="Texfina.Core.Common" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link href="../Styles/jquery-ui.custom.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        window.onload = function () {
            var menuTable = document.getElementById('<%=mnuToolbar.ClientID %>');
            var menuLinks = menuTable.getElementsByTagName("a");
            if (menuLinks != null) {
                switch (menuLinks.length) {
                    case 2:
                        menuLinks[0].onclick = function () { return validateEditForm('_BTTSAVE') }
                        break;

                    case 3:
                        menuLinks[0].onclick = function () { return validateEditForm('_BTTSAVE') }
                        menuLinks[1].onclick = function () { return validateEditForm('_BTTSAVNEW') }
                        break;
                }
            }

            var mnuGrid = document.getElementById('<%=mnuGrid.ClientID %>');
            var mnuGridLinks = mnuGrid.getElementsByTagName("a");
            if (mnuGridLinks != null) {
                switch (mnuGridLinks.length) {
                    case 1:
                        mnuGridLinks[0].onclick = function () { return validateEditFormGrid('_BTTNEW') }
                        break;
                }
            }

            this.ResizeGrid();       
            this.MessageOnPostback();
        }

        function validateGridCommands(key, rowIndex) {
            var row = getGridRowByIndex('<%= grdList.ClientID %>', rowIndex);
            if (getObjInnerText(row.cells[parseInt('<%=_GRDLIST_STANULADO %>')]) == '<%=ConstFlagEstado.ACTIVADO %>') {
               AtentionAlert('El Registro se encuentra eliminado, no puede realizar ninguna accion.');
                return false;
            }
            return true;
        }

        function ResizeGrid() {
            //            internalGridResize("<%= grdList.ClientID %>");
        }
        function GetSaldoPeriodo() {
            var saldo = 0;
            var grd = document.getElementById('<%= grdListSaldos.ClientID %>');
            for (var i = 0; i < grd.rows.length; i++) {
                if (parseFloat(grd.rows[i].cells[0].innerHTML) <= parseFloat('<%= Session[ConstSessionVar.PERIODO].ToString() %>'))
                { saldo = saldo + parseFloat(grd.rows[i].cells[1].innerHTML); }
            }
            if (saldo == 'undefined')
                saldo = -1;
            return saldo - parseFloat(document.getElementById('<%= hdnnuDiasTotal.ClientID %>'));
        }

        function panelOnUpdating() {
            updatePanelAnimationUpdating();
        }

        function panelOnUpdated() {
            ResizeGrid();
            updatePanelAnimationUpdated();
        }

        function calcularMonto() {
            if (document.getElementById('<%= chkCalcular.ClientID %>').checked) {
                document.getElementById('<%= txtmtMontoPp.ClientID %>').disabled = true;
                document.getElementById('<%= txtmtMontoPp.ClientID %>').value = '0.00';
            }
            else {
                document.getElementById('<%= txtmtMontoPp.ClientID %>').disabled = false;
            }

        }

        $(document).ready(function () {
            Sys.Application.add_load(end_page);

        });

        function end_page() {
            if (document.getElementById('<%= chkCalcular.ClientID %>').checked) {
                document.getElementById('<%= txtmtMontoPp.ClientID %>').disabled = true;
                document.getElementById('<%= txtmtMontoPp.ClientID %>').value = '0.00';
            }
            else {
                document.getElementById('<%= txtmtMontoPp.ClientID %>').disabled = false;
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="ToolBar">
        <asp:Menu ID="mnuToolbar" runat="server" Orientation="Horizontal" CssClass="ToolBarControl"
            OnMenuItemClick="mnuToolbar_MenuItemClick">
            <Items>
                <asp:MenuItem Text="Guardar" Value="_BTTSAVE" ImageUrl="../Images/Icons/Enabled/SAVE.png">
                </asp:MenuItem>
                <asp:MenuItem Text="Salir" Value="_BTTEXIT" ImageUrl="../Images/Icons/Enabled/BACK.png">
                </asp:MenuItem>
            </Items>
        </asp:Menu>
    </div>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div class="DataHeader">
                <table id="TableDataHeader" cellpadding="0" cellspacing="0">
                    <tr>
                        <td colspan="3">
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 5px">
                            &nbsp;
                        </td>
                        <td>
                            <div style="border: 1px solid #ccc; border-radius: 5px; -moz-border-radius: 5px;
                                -webkit-border-radius: 5px; -ms-border-radius: 5px;">
                                <table width="100%" cellpadding="0" cellspacing="2">
                                    <tr>
                                        <td colspan="13">
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 5px;">
                                            &nbsp;
                                        </td>
                                        <td style="width: 110px;">
                                            Cod. Descanso
                                        </td>
                                        <td colspan="7">
                                            <esd:esdMaskedTextBox runat="server" ID="txtidVacaDesca" Width="100px" Mask="9999">
                                            </esd:esdMaskedTextBox>
                                        </td>
                                        <td colspan="3" rowspan="3">
                                            <esd:esdGridView CssClass="esdGridView" ID="grdListSaldos" runat="server" ScrollWidth="200px"
                                                ScrollHeight="100px" Width="100%" ShowHeaderWhenEmpty="True" AutoGenerateColumns="False"
                                                DataKeyNames="idPeriVac" OnRowCommand="grdList_RowCommand" OnRowDataBound="grdList_RowDataBound">
                                                <Columns>
                                                    <asp:BoundField DataField="idPeriVac" HeaderText="Periodo"></asp:BoundField>
                                                    <asp:BoundField DataField="mtSaldo" HeaderText="Saldo Dias"></asp:BoundField>
                                                </Columns>
                                                <EmptyDataTemplate>
                                                    <div id="gridempty">
                                                        <asp:Image ID="imgEmpty" runat="server" ImageUrl="../Images/Controls/Attention.png" />
                                                        &nbsp;No existen registros para esta solicitud.
                                                    </div>
                                                </EmptyDataTemplate>
                                            </esd:esdGridView>
                                        </td>
                                        <td style="width: 5px;">
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 5px;">
                                            &nbsp;
                                        </td>
                                        <td>
                                            Personal
                                        </td>
                                        <td colspan="2">
                                            <esd:esdButtonTextBox runat="server" ID="txtidPersonal" Width="350px"></esd:esdButtonTextBox>
                                        </td>
                                        <td style="width: 30px;">
                                            &nbsp;
                                        </td>
                                        <td>
                                            Forma de Pago
                                        </td>
                                        <td colspan="2">
                                            <asp:DropDownList runat="server" ID="ddlidForPago" Width="180px">
                                            </asp:DropDownList>
                                        </td>
                                        <td style="width: 30px;">
                                            &nbsp;
                                        </td>
                                        <td style="width: 5px;">
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 5px;">
                                            &nbsp;
                                        </td>
                                        <td>
                                            Observacion
                                        </td>
                                        <td colspan="2">
                                            <esd:esdTextBox ID="txtdsObservacion" runat="server" TextMode="MultiLine" Height="45px"
                                                Width="350px"></esd:esdTextBox>
                                        </td>
                                        <td colspan="5">
                                            &nbsp;
                                        </td>
                                        <td style="width: 5px;">
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="13">
                                            &nbsp;
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </td>
                        <td style="width: 5px">
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3">
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </div>
            <div class="DataDetail">
                <table width="100%" cellpadding="0" cellspacing="0">
                    <tr>
                        <td style="width: 5px;">
                            &nbsp;
                        </td>
                        <td>
                            <div class="ToolBarGrid">
                                <asp:Menu ID="mnuGrid" runat="server" Orientation="Horizontal" CssClass="ToolBarControl"
                                    OnMenuItemClick="mnuGrid_MenuItemClick">
                                    <Items>
                                        <asp:MenuItem Text="Nuevo" Value="_BTTNEW" ImageUrl="../Images/Icons/Enabled/New.png">
                                        </asp:MenuItem>
                                    </Items>
                                </asp:Menu>
                            </div>
                            <esd:esdGridView CssClass="esdGridView" ID="grdList" runat="server" ScrollWidth="100%"
                                Width="100%" ShowHeaderWhenEmpty="True" AutoGenerateColumns="False" DataKeyNames="nuSecuen"
                                OnRowCommand="grdList_RowCommand" OnRowDataBound="grdList_RowDataBound">
                                <Columns>
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:ImageButton ID="grdBttCmdEdit" CommandName="CmdEdit" CommandArgument="<%# Container.DataItemIndex %>"
                                                runat="server" ImageUrl="../Images/Icons/Enabled/Edit.png" ToolTip="Editar Contrato" />
                                        </ItemTemplate>
                                        <HeaderStyle Width="22px" />
                                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                    </asp:TemplateField>
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:ImageButton ID="grdBttCmdDel" CommandName="CmdDel" CommandArgument="<%# Container.DataItemIndex %>"
                                                runat="server" ImageUrl="../Images/Icons/Enabled/Delete.png" ToolTip="Eliminar Contrato" />
                                        </ItemTemplate>
                                        <HeaderStyle Width="22px" />
                                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="nuSecuen" HeaderText="Nro" ItemStyle-HorizontalAlign="Center">
                                    </asp:BoundField>
                                    <asp:BoundField DataField="idPlanilla" HeaderStyle-CssClass="hideDataGridColumn"
                                        ItemStyle-CssClass="hideDataGridColumn"></asp:BoundField>
                                    <asp:BoundField DataField="dsPlanilla" HeaderText="Planilla"></asp:BoundField>
                                    <asp:BoundField DataField="idForPago" HeaderStyle-CssClass="hideDataGridColumn" ItemStyle-CssClass="hideDataGridColumn">
                                    </asp:BoundField>
                                    <asp:BoundField DataField="dsForPago" HeaderText="Forma Pago"></asp:BoundField>
                                    <asp:BoundField DataField="idConRemu" HeaderStyle-CssClass="hideDataGridColumn" ItemStyle-CssClass="hideDataGridColumn">
                                    </asp:BoundField>
                                    <asp:BoundField DataField="dsConRemu" HeaderText="Concepto"></asp:BoundField>
                                    <asp:BoundField DataField="fedesde" DataFormatString="{0:dd/MM/yyyy}" HeaderText="Fecha">
                                    </asp:BoundField>
                                    <asp:BoundField DataField="idPeriVac" HeaderText="Periodo<br/>Vacaciones" HtmlEncode="false"
                                        ItemStyle-HorizontalAlign="Center"></asp:BoundField>
                                    <asp:BoundField DataField="nuDiasVaca" HeaderText="Nro Dias" HtmlEncode="false" ItemStyle-HorizontalAlign="Center">
                                    </asp:BoundField>
                                      <asp:BoundField DataField="mtVaca" HeaderText="Monto" HtmlEncode="false" ItemStyle-HorizontalAlign="Center">
                                    </asp:BoundField>
                                    <asp:BoundField DataField="dsStVaca" HeaderText="Estado"></asp:BoundField>
                                    <asp:BoundField DataField="stVaca" HeaderStyle-CssClass="hideDataGridColumn" ItemStyle-CssClass="hideDataGridColumn">
                                    </asp:BoundField>
                                    <asp:BoundField DataField="stAnulado" HeaderStyle-CssClass="hideDataGridColumn" ItemStyle-CssClass="hideDataGridColumn">
                                    </asp:BoundField>
                                </Columns>
                                <EmptyDataTemplate>
                                    <div id="gridempty">
                                        <asp:Image ID="imgEmpty" runat="server" ImageUrl="../Images/Controls/Attention.png" />
                                        &nbsp;No existen registros para esta solicitud.
                                    </div>
                                </EmptyDataTemplate>
                            </esd:esdGridView>
                        </td>
                        <td style="width: 5px;">
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </div>
            <asp:HiddenField ID="hdnMsgOPB" runat="server" />
            <asp:HiddenField ID="hdnModalPopup" runat="server" />
            <asp:HiddenField ID="hdnidPersonal" runat="server" />
            <asp:HiddenField ID="hdnidPlanilla" runat="server" />
            <asp:HiddenField ID="hdnnuProcAnual" runat="server" />
            <asp:HiddenField ID="hdnnuDiasMax" runat="server" />
            <asp:HiddenField ID="hdnFeIniProcAnual" runat="server" />
            <asp:HiddenField ID="hdnFeFinProcAnual" runat="server" />
            <asp:HiddenField ID="hdnMaxDiasRangoFe" runat="server" />
            <asp:HiddenField ID="hdnfeIngrPlani" runat="server" />
            <asp:HiddenField ID="hdnnuDiasTotal" runat="server" />
            <asp:HiddenField ID="hdnidPeriodo" runat="server" />
            <asp:Panel runat="server" ID="PnlPopup" CssClass="modalPopup" Width="560px" Style="display: none;">
                <table width="100%" cellpadding="0" cellspacing="2">
                    <tr>
                        <td colspan="3">
                            <div class="modalPopupHeader">
                                &nbsp;&nbsp;&nbsp;<asp:Label ID="lblTitlePopup" runat="server"></asp:Label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 5px;">
                            &nbsp;
                        </td>
                        <td>
                            <table width="100%" cellpadding="0" cellspacing="2">
                                <tr>
                                    <td colspan="13">
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 5px;">
                                        &nbsp;
                                    </td>
                                    <td>
                                        Planilla
                                    </td>
                                    <td colspan="8">
                                        <esd:esdButtonTextBox ID="txtidPlanillaPp" runat="server" Width="300px">
                                        </esd:esdButtonTextBox>
                                    </td>
                                    <td style="width: 5px;">
                                        &nbsp;
                                    </td>
                                    <td rowspan="5">
                                        <esd:esdGridView CssClass="esdGridView" ID="grdListSaldoPp" runat="server" ScrollWidth="120px"
                                            ScrollHeight="100px" Width="100%" ShowHeaderWhenEmpty="True" AutoGenerateColumns="False"
                                            DataKeyNames="idPeriVac" OnRowCommand="grdList_RowCommand" OnRowDataBound="grdList_RowDataBound">
                                            <Columns>
                                                <asp:BoundField DataField="idPeriVac" HeaderText="Periodo"></asp:BoundField>
                                                <asp:BoundField DataField="mtSaldo" HeaderText="Saldo<br/>Dias" HtmlEncode="false">
                                                </asp:BoundField>
                                            </Columns>
                                            <EmptyDataTemplate>
                                                <div id="gridempty">
                                                    <asp:Image ID="imgEmpty" runat="server" ImageUrl="../Images/Controls/Attention.png" />
                                                    &nbsp;No existen registros para esta solicitud.
                                                </div>
                                            </EmptyDataTemplate>
                                        </esd:esdGridView>
                                    </td>
                                    <td style="width: 5px;">
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 5px;">
                                        &nbsp;
                                    </td>
                                    <td>
                                        Fecha Salida
                                    </td>
                                    <td colspan="2">
                                        <esd:esdDateTextBox ID="txtfeVacaPp" runat="server" Width="100px"></esd:esdDateTextBox>
                                    </td>
                                    <td style="width: 5px;">
                                        &nbsp;
                                    </td>
                                    <td>
                                        Ingr.Planilla
                                    </td>
                                    <td colspan="4">
                                        <esd:esdTextBox ID="txtfeIngrPlaniPp" ReadOnly="true" runat="server" Width="92px"></esd:esdTextBox>
                                    </td>
                                    <td style="width: 5px;">
                                        &nbsp;
                                    </td>
                                    <td style="width: 5px;">
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 5px;">
                                        &nbsp;
                                    </td>
                                    <td>
                                    </td>
                                    <td colspan="8">
                                    </td>
                                    <td style="width: 5px;">
                                        &nbsp;
                                    </td>
                                    <td style="width: 5px;">
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 5px;">
                                        &nbsp;
                                    </td>
                                    <td>
                                        N° Dias
                                    </td>
                                    <td colspan="8">
                                        <esd:esdNumericTextBox ID="txtnuDiasVacaPp" NumericType="Decimal" runat="server"
                                            Width="100px"></esd:esdNumericTextBox>
                                    </td>
                                    <td style="width: 5px;">
                                        &nbsp;
                                    </td>
                                    <td style="width: 5px;">
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 5px;">
                                        &nbsp;
                                    </td>
                                    <td>
                                        Monto
                                    </td>
                                    <td colspan="2">
                                        <esd:esdNumericTextBox ID="txtmtMontoPp" NumericType="Decimal" runat="server" Width="100px"></esd:esdNumericTextBox>
                                    </td>
                                    <td colspan="6">
                                        <asp:CheckBox ID="chkCalcular" runat="server" Text="Calcular Monto" Checked="true" />
                                    </td>
                                    <td style="width: 5px;">
                                        &nbsp;
                                    </td>
                                    <td style="width: 5px;">
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="13">
                                        &nbsp;
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td style="width: 5px;">
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 5px;">
                            &nbsp;
                        </td>
                        <td align="right">
                            <esd:esdButton ID="bttOkPopup" runat="server" Text="Aceptar" Width="80px" OnClick="bttOkPopup_Click">
                            </esd:esdButton>
                            <esd:esdButton ID="bttCancelPopup" runat="server" Text="Cancelar" Width="80px"></esd:esdButton>
                        </td>
                        <td style="width: 5px;">
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3">
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </asp:Panel>
            <ajax:ModalPopupExtender runat="server" ID="mdlPopup" PopupControlID="PnlPopup" BackgroundCssClass="modalBackground"
                TargetControlID="hdnModalPopup">
            </ajax:ModalPopupExtender>
        </ContentTemplate>
    </asp:UpdatePanel>
    <ajax:UpdatePanelAnimationExtender ID="upae" BehaviorID="animation" runat="server"
        TargetControlID="updatePanel1">
        <animations>
        <OnUpdating>
        <Parallel duration="0.5">
            <ScriptAction Script="panelOnUpdating();" />  
        </Parallel>
        </OnUpdating>
        <OnUpdated>
        <Parallel duration="0.5">
            <ScriptAction Script="panelOnUpdated();" /> 
        </Parallel> 
        </OnUpdated>
    </animations>
    </ajax:UpdatePanelAnimationExtender>
    <div id="updateProgressDiv" class="updateProgress" style="display: none">
        <table width="100%">
            <tr>
                <td valign="middle">
                    <img src="../Images/Controls/Loading.gif" />
                </td>
                <td valign="middle">
                    <span class="updateProgressMessage">Cargando ...</span>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
